<?php
$data = array("a","b","c","d","e","f","g","h","i");
print_r($data);
if(preg_match('@\s+http://([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i'," ".$data[4],$url)){
	//print_r($url);
	$url[0] = str_replace(" ","",$url[0]);
$https = false;
}elseif($data[2] == "http"){
if(preg_match('@//([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i',$data[3],$url)){$url[0] = "http:".$url[0];$https = false;
}
}elseif(preg_match('@\s+www\.([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i'," ".$data[4],$url)){
$url[0] = str_replace(" ","",$url[0]);
$https = false;}elseif(preg_match('@\swww\.([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i'," ".$data[2],$url)){
$url[0] = str_replace(" ","",$url[0]);$https = false;
}elseif(preg_match('@\s+https://([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i'," ".$data[4],$url)){
$url[0] = str_replace(" ","",$url[0]);$https = true;}elseif($data[2] =="https"){
if(preg_match('@//([^/,\s\.]+\.)+[a-zA-Z]+(/[^\s]*)?@i',$data[3],$url)){
//print_r($url);
$url[0] = "https:".$url[0];
$https = true;
}
}
if($url[0] != "" && $data[1][0] == '#'){
$ctimer = 2;
$dltimer = 2;
$url = str_replace(array("http://","https://"),"",$url[0]);
preg_match("@[^/]+@",$url,$matches);$host = $matches[0];echo "HOST:".$host."\n";
if(!$https){$fp = @fsockopen($host, 80, $errno, $errstr, $ctimer);
}else{$fp = @fsockopen("ssl://".$host, 443, $errno, $errstr, $ctimer);}if (!$fp){echo"host ($host) $errstr ($errno)\n";}else{if(preg_match("@/[^\s]*@",$url,$matches)){$url = $matches[0];}else{$url = "/";}echo "URL:".$url."\n";$out = "GET ".$url." HTTP/1.1\r\n";$out .= "Host: ".$host."\r\n";$out .= "User-Agent: Jacqli/0.2 jacqli.mir@gmail.com\r\n";$out .= "Connection: Close\r\n\r\n";fwrite($fp, $out);$url = "";$time = time();$timee = time();while (!feof($fp) && $timee-$time <= $dltimer) {$url .= fread($fp, 1000);$timee = time();}fclose($fp);preg_match("@<title>[^<]*@i",$url,$matches);echo "URL-match: ".$matches[0]."\n";$matches[0] = preg_replace("@[ \t]+@"," ",$matches[0]);$title = html_entity_decode(substr(preg_replace("@<title>@i","",str_replace(array("\n","\r"),"",$matches[0])),0,300),ENT_QUOTES,"UTF-8");echo "TITLE:".$title."\n";if($title == "301 Moved" || $title == "301 Moved Permanently" || $title == "302 Found" || $title == "303 See Other" || $title == "302 Moved"){echo "URL:".$url."\n";preg_match("@Location:[^\n\r]+@i", $url,$url);echo "URL2:".$url[0]."\n";$url = str_replace(array("Location:","http://"," "),"",$url[0]);preg_match("@[^/]+@",$url,$matches);$host = $matches[0];echo"HOST:".$host."\n";$fp = @fsockopen($host, 80, $errno, $errstr, $ctimer);if (!$fp){echo "host ($host) $errstr ($errno)\n";}else{if(preg_match("@/[^\s]*@",$url,$matches)){$url = $matches[0];}else{$url = "/";}$out = "GET ".$url." HTTP/1.1\r\n";$out .= "Host: ".$host."\r\n";$out .= "User-Agent: Jacqli/0.2 jacqli.mir@gmail.com\r\n";$out .= "Connection: Close\r\n\r\n";fwrite($fp, $out);$url = "";$time= time();$timee = time();while (!feof($fp) && $timee-$time <= $dltimer) {$url .= fread($fp, 1000);$timee = time();}fclose($fp);preg_match("@<title>[^<]*@i",$url,$matches);echo "URL-match: ".$matches[0]."\n";$matches[0] = preg_replace("@[ \t]+@"," ",$matches[0]);$title = html_entity_decode(substr(preg_replace("@<title>@i","",str_replace(array("\n","\r"),"",$matches[0])),0,300),ENT_QUOTES,"UTF-8");}}if($title != "")$data[6] = $title;else$data[6] = false;}}return $data;
?>